package LoginPackage;


import org.openqa.selenium.By;
import org.testng.annotations.Test;
import PagePackage.MyPageFactory;
import PagePackage.internalPageClass;
import PagePackage.userContactInfoPageClass;
import PagePackage.usersPageClass;

public class UsersSearch extends TestBaseClass {
	
	@Test (priority=0)
	 public void AdminSearchUserByEmail() {
		goToMainPage();
		checkPage()
		.loginAs(adminEmail, adminPassword)
		.clickusertab()
		.findUserByEmail(adminEmail)
		.clickSearch()
		.scrollAndClick(0, 0, "//*[text()='"+adminEmail+"']")
		.logout();
		
}

	@Test (priority=1)
	 public void AdminSearchUserByFirstName() {
		goToMainPage();
		checkPage()
		.loginAs(adminEmail, adminPassword)
		.clickusertab()
		.clickSearch()
		.findUserByFirstName("First Name")
		.scrollAndClick3(0, 0, "//*[contains(text(),'First Name')]")
		.findFirstName("//*[contains(text(),'First Name')]")
		.logout();
		
}
	
	@Test (priority=2)
	 public void AdminSearchUserBylastName() {
		goToMainPage();
		checkPage()
		.loginAs(adminEmail, adminPassword)
		.clickusertab()
		
		.findUserByLastName("Last Name")
		.clickSearch()
		.scrollAndClick3(0, 0, "//*[contains(text(),'Last Name')]")
		.findFirstName("//*[contains(text(),'Last Name')]")
		
		.logout();
		
}
	


	@Test (priority=3)
	 public void AdminSearchUserByAdminRole() {
		goToMainPage();
		checkPage()
		.loginAs(adminEmail, adminPassword)
		.clickusertab()
		
		.findUserByRole("Admin")
		.clickSearch()
		.clickonFirstResult()
	    .logout();

}

	@Test (priority=4)
	 public void AdminSearchUserByIndexerRole() {
		goToMainPage();
		checkPage()
		.loginAs(adminEmail, adminPassword)
		.clickusertab()
		.findUserByRole("Indexer")
		.clickSearch()
		.clickonFirstResult()
		.roleTabClick();
		driver.findElement(By.xpath("//span[contains(text(),'indexer')]"));
		MyPageFactory.getPage(driver, userContactInfoPageClass.class).roleTabClick()
		.logout();

}
	@Test (priority=5)
	 public void AdminSearchUserByHeadCoachRole() {
		goToMainPage();
		checkPage()
		.loginAs(adminEmail, adminPassword)
		.clickusertab()
		.findUserByRole("Head Coach")
		.clickSearch().clickonFirstResult()
		.roleTabClick();
		driver.findElement(By.xpath("//span[contains(text(),'Coach')]"));
		MyPageFactory.getPage(driver, userContactInfoPageClass.class).roleTabClick()
		.logout();

}
	@Test (priority=6)
	 public void AdminSearchUserByAssistantCoachRole() {
		goToMainPage();
		checkPage()
		.loginAs(adminEmail, adminPassword)
		.clickusertab()
		.findUserByRole("Assistant Coach")
		.clickSearch()
		.clickonFirstResult()
		.roleTabClick();
		driver.findElement(By.xpath("//span[contains(text(),'Coach')]"));
		MyPageFactory.getPage(driver, userContactInfoPageClass.class).roleTabClick()
		.logout();

}
	@Test (priority=7)
	 public void AdminSearchUserByAthleteRole() {
		goToMainPage();
		checkPage()
		.loginAs(adminEmail, adminPassword)
		.clickusertab()
		.findUserByRole("Athlete")
		.clickSearch()
		.clickonFirstResult()
		.roleTabClick();
		driver.findElement(By.xpath("//span[contains(text(),'athlete')]"));
		MyPageFactory.getPage(driver, userContactInfoPageClass.class).roleTabClick()
		.logout();
	}
	
	@Test (priority=8)
	 public void AdminSearchUserByActiveStatus() {
		goToMainPage();
		checkPage()
		.loginAs(adminEmail, adminPassword)
		.clickusertab()
		.findUserByStatus("Active")
		.clickSearch()
		.checkStatus("Active");
		
		driver.get("https://www-dev.krossover.com/intelligence-qa/account");
		MyPageFactory.getPage(driver, internalPageClass.class).clickusertab()
		.logout();
	}
	
	@Test (priority=9)
	 public void AdminSearchUserByInactiveStatus() {
		goToMainPage();
		checkPage()
		.loginAs(adminEmail, adminPassword)
		.clickusertab()
		.findUserByStatus("Not Active")
		.clickSearch()
		.checkStatus("Inactive");
		
		driver.get("https://www-dev.krossover.com/intelligence-qa/account");
		MyPageFactory.getPage(driver, internalPageClass.class).clickusertab()
		.logout();
		
	}
	
	@Test (priority=10)
	 public void AdminSearchUserByEmailFirstLastRoleStatus() {
		goToMainPage();
		checkPage()
		.loginAs(adminEmail, adminPassword)
		.clickusertab()
		.findUserByEmail("victoria@victoria.com")
		.findUserByRole("Indexer")
		.findUserByFirstName("Victoria")
		.findUserByLastName("Davydkina")
		.findUserByStatus("Active")
		.clickSearch()
		.checkMultiStatus("Active");
	
		MyPageFactory.getPage(driver, usersPageClass.class).scrollAndClick(0, 0, "//*[text()='victoria@victoria.com']")
		.findFirstName("//*[contains(text(),'Victoria')]")
		.findFirstName("//*[contains(text(),'Davydkina')]");
		
		MyPageFactory.getPage(driver, userContactInfoPageClass.class).roleTabClick();
		driver.findElement(By.xpath("//span[contains(text(),'athlete')]"));
		
		MyPageFactory.getPage(driver, userContactInfoPageClass.class).roleTabClick();
		driver.findElement(By.xpath("//span[contains(text(),'athlete')]"));
		MyPageFactory.getPage(driver, userContactInfoPageClass.class).roleTabClick()
		.logout();
	}
	
	
	@Test (priority=11)
	 public void SASearchUserByEmail() {
		goToMainPage();
		checkPage()
		.loginAs(saEmail, saPassword)
		.clickusertab()
		.findUserByEmail(adminEmail)
		.clickSearch()
		.scrollAndClick(0, 0, "//*[text()='"+adminEmail+"']")
		.logout();
		
}

	@Test (priority=12)
	 public void SASearchUserByFirstName() {
		goToMainPage();
		checkPage()
		.loginAs(saEmail, saPassword)
		.clickusertab()
		.clickSearch()
		.findUserByFirstName("First Name")
		.scrollAndClick3(0, 0, "//*[contains(text(),'First Name')]")
		.findFirstName("//*[contains(text(),'First Name')]")
		.logout();
		
}
	
	@Test (priority=13)
	 public void SASearchUserBylastName() {
		goToMainPage();
		checkPage()
		.loginAs(saEmail, saPassword)
		.clickusertab()
		
		.findUserByLastName("Last Name")
		.clickSearch()
		.scrollAndClick3(0, 0, "//*[contains(text(),'Last Name')]")
		.findFirstName("//*[contains(text(),'Last Name')]")
		
		.logout();
		
}
	


	@Test (priority=14)
	 public void SASearchUserByAdminRole() {
		goToMainPage();
		checkPage()
		.loginAs(saEmail, saPassword)
		.clickusertab()
		
		.findUserByRole("Admin")
		.clickSearch();
		
		MyPageFactory.getPage(driver, userContactInfoPageClass.class).roleTabClick();
		driver.findElement(By.xpath("//span[contains(text(),'admin')]")).click();
		MyPageFactory.getPage(driver, internalPageClass.class).logout();

}

	@Test (priority=15)
	 public void SASearchUserByIndexerRole() {
		goToMainPage();
		checkPage()
		.loginAs(saEmail, saPassword)
		.clickusertab()
		.findUserByRole("Indexer")
		.clickSearch()
		.clickonFirstResult()
		.roleTabClick();
		driver.findElement(By.xpath("//span[contains(text(),'indexer')]"));
		MyPageFactory.getPage(driver, userContactInfoPageClass.class).roleTabClick()
		.logout();

}
	@Test (priority=16)
	 public void SASearchUserByHeadCoachRole() {
		goToMainPage();
		checkPage()
		.loginAs(saEmail, saPassword)
		.clickusertab()
		.findUserByRole("Head Coach")
		.clickSearch()
		.clickonFirstResult()
		.roleTabClick();
		driver.findElement(By.xpath("//span[contains(text(),'Coach')]"));
		MyPageFactory.getPage(driver, userContactInfoPageClass.class).roleTabClick()
		.logout();

}
	@Test (priority=17)
	 public void SASearchUserByAssistantCoachRole() {
		goToMainPage();
		checkPage()
		.loginAs(saEmail, saPassword)
		.clickusertab()
		.findUserByRole("Assistant Coach")
		.clickSearch()
		.clickonFirstResult()
		.roleTabClick();
		driver.findElement(By.xpath("//span[contains(text(),'Coach')]"));
		MyPageFactory.getPage(driver, userContactInfoPageClass.class).roleTabClick()
		.logout();

}
	@Test (priority=18)
	 public void SASearchUserByAthleteRole() {
		goToMainPage();
		checkPage()
		.loginAs(saEmail, saPassword)
		.clickusertab()
		.findUserByRole("Athlete")
		.clickSearch()
		.clickonFirstResult()
		.roleTabClick();
		driver.findElement(By.xpath("//span[contains(text(),'athlete')]"));
		MyPageFactory.getPage(driver, userContactInfoPageClass.class).roleTabClick()
		.logout();
	}
	
	@Test (priority=19)
	 public void SASearchUserByActiveStatus() {
		goToMainPage();
		checkPage()
		.loginAs(saEmail, saPassword)
		.clickusertab()
		.findUserByStatus("Active")
		.clickSearch()
		.checkStatus("Active");
		
		driver.get("https://www-dev.krossover.com/intelligence-qa/account");
		MyPageFactory.getPage(driver, internalPageClass.class).clickusertab()
		.logout();
	}
	
	@Test (priority=20)
	 public void SASearchUserByInactiveStatus() {
		goToMainPage();
		checkPage()
		.loginAs(saEmail, saPassword)
		.clickusertab()
		.findUserByStatus("Not Active")
		.clickSearch()
		.checkStatus("Inactive");
		
		driver.get("https://www-dev.krossover.com/intelligence-qa/account");
		MyPageFactory.getPage(driver, internalPageClass.class).clickusertab()
		.logout();
		
	}
	
	@Test (priority=21)
	 public void SASearchUserByEmailFirstLastRoleStatus() {
		goToMainPage();
		checkPage()
		.loginAs(saEmail, saPassword)
		.clickusertab()
		.findUserByEmail("victoria@victoria.com")
		.findUserByRole("Indexer")
		.findUserByFirstName("Victoria")
		.findUserByLastName("Davydkina")
		.findUserByStatus("Active")
		.clickSearch()
		.checkMultiStatus("Active");
	
		MyPageFactory.getPage(driver, usersPageClass.class).scrollAndClick(0, 0, "//*[text()='victoria@victoria.com']")
		.findFirstName("//*[contains(text(),'Victoria')]")
		.findFirstName("//*[contains(text(),'Davydkina')]");
		
		MyPageFactory.getPage(driver, userContactInfoPageClass.class).roleTabClick();
		driver.findElement(By.xpath("//span[contains(text(),'athlete')]"));
		
		MyPageFactory.getPage(driver, userContactInfoPageClass.class).roleTabClick();
		driver.findElement(By.xpath("//span[contains(text(),'athlete')]"));
		MyPageFactory.getPage(driver, userContactInfoPageClass.class).roleTabClick()
		.logout();
	}
	
	@Test (priority=22)
	public void SASearchUserNoResults() {
	goToMainPage();
	checkPage()
	.loginAs(saEmail, saPassword)
	.clickusertab()
	.findUserByEmail("victoria123@victoria.com")
	.clickSearch()
	.noUserResults()
	.logout();
	}
	
	@Test (priority=23)
	public void AdminSearchUserNoResults() {
	goToMainPage();
	checkPage()
	.loginAs(adminEmail, adminPassword)
	.clickusertab()
	.findUserByEmail("victoria123@victoria.com")
	.clickSearch()
	.noUserResults()
	.logout();
	}
}







